<?php
// +----------------------------------------------------------------------
//            -------------------------
//           /   / ----------------\  \
//          /   /             \  \
//         /   /              /  /
//        /   /    /-------------- /  /
//       /   /    /-------------------\  \
//      /   /                   \  \
//     /   /                     \  \
//    /   /                      /  /
//   /   /      /----------------------- /  /
//  /-----/      /---------------------------/
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://baimifan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 汪利东,2016-04-19 17:48
// +----------------------------------------------------------------------

namespace Common\Model;


use Think\Model;

class SettingModel extends Model
{
    public function getValue($name)
    {
        return $this->where(['name' => $name])->getField('value');
    }

    public function getAll()
    {
        $result = [];
        
        $data = $this->select();
        foreach ($data as $k => $v) {
            $result[$v['name']] = $v['value'];
        }

        return $result;
    }

    public function setValue($name, $value)
    {
        return $this->where(['name' => $name])->setField($name, $value);
    }
}